<?php
require_once($server->my_site[0]->path.$server->my_site[0]->folder."distributor_manage.php");

$distributor->id or exit("Área reservada a distribuidores");

// First we search for if the order is in the distributor arrays
$myorder=null;
foreach ($distributor->unprocessed_orders as $order) {
	if ($order->id==$_POST['order_id']) {
		$myorder=$order;
		break;
	}
}
if (!$myorder) {
	foreach ($distributor->processed_orders as $order) {
		if ($order->id==$_POST['order_id']) {
			$myorder=$order;
			break;
		}
	}
}

$myorder->comments=$_POST['comments'];
$sql = "update " .
	TABLE_ORDERS .
	" set".
	" comments=" . "'" . $myorder->comments . "'" .
	" where id=" . $myorder->id .
	" LIMIT 1";
$result = $server->db->link->query($sql);
$save_check = ($server->db->link->affected_rows > 0);
if ( $save_check) {
?>
<div style="margin: 1em 0;">
<p>Comentario actualizado.</p>
</div>
<?php
}
?>
